package com.yuesystem.service.impl;


import com.yuesystem.config.SmsConfig;
import com.yuesystem.service.MsmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * 发送验证码接口实现类.
 */
@Service
public class MsmServiceImpl implements MsmService {
  @Autowired
  private SmsConfig smsConfig;
  
  @Override
  public boolean send(String phone, String code) {
    // 判断手机号是否为空
    if (StringUtils.isEmpty(phone)) {
      return false;
    }
    // 整合榛子云的短信服务发送
    try {
      smsConfig.sendMessage(code, phone);
    } catch (Exception e) {
      // 打印相对应的异常
      e.printStackTrace();
      return false;
    }
    return true;
  }
}

